<template>
  <div class="progress-bar">
    <div
      class="progress-bar-fill"
      :style="{
        width: `${progress}%`,
        backgroundColor: color
      }"
    >
      <span class="progress-bar-label" v-if="showLabel">{{ progress }}%</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProgressBar',
  props: {
    progress: {
      type: Number,
      required: true,
      default: 0
    },
    color: {
      type: String,
      default: 'hsla(209, 79%, 65%, 1)' // 默认颜色
    },
    showLabel: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style scoped>
.progress-bar {
  width: 100%;
  background-color: hsla(0, 0%, 100%, 0.25);
  overflow: hidden;
  position: relative;
  height: 10px;
}

.progress-bar-fill {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  transition: width 0.25s ease;
  color: #fff;
  font-weight: bold;
  position: relative;
  clip-path: polygon(0% 0%, calc(100% - 8px) 0%, 100% 100%, 0 100%);
}

.progress-bar-label {
  position: absolute;
  width: 100%;
  text-align: center;
}
</style>
